STEP 14: The ball should change direction if it hits a brick!

  • In GRAPHICS from add Set x Speed inside the second if-statement.
  • Change the argument in .set_x_speed() to -ball_x_speed.
  • Add Set y Speed inside the second if-block. Let's edit the argument to add a little randomness to the motion!
  • Delete the 5 and type random.randint(-5, 5). This sets the y speed to a random integer between -5 and 5!

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)